from django.contrib import admin
from product.models import Product

@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
    """
    产品基础信息管理界面配置
    """
    list_display = ('product_id', 'product_type', 'sku', 'name', 'spc', 'status', 'category_id', 'create_time', 'sku_supplier', 'barcode')
    search_fields = ('sku', 'name', 'description', 'sku_supplier', 'barcode')
    list_filter = ('status', 'create_time', 'inventory_method', 'costing_method', 'is_batch_tracked', 'is_serial_tracked')
    readonly_fields = ('product_id', 'create_time', 'update_time')
    fieldsets = (
        ('基本信息', {
            'fields': ('sku', 'product_type', 'name', 'spc', 'description', 'status', 'sku_supplier', 'barcode', 'version')
        }),
        ('分类与计量', {
            'fields': ('category_id', 'unit_pr', 'unit_wh', 'unit_use', 'unit_rate')
        }),
        ('库存与成本', {
            'fields': ('inventory_method', 'costing_method', 'standard_cost', 'current_cost', 'last_purchase_price', 'list_price')
        }),
        ('跟踪与有效期', {
            'fields': ('is_batch_tracked', 'is_serial_tracked', 'shelf_life_days')
        }),
        ('库存控制', {
            'fields': ('safety_stock', 'reorder_point', 'max_stock', 'default_warehouse_id', 'default_location')
        }),
        ('采购信息', {
            'fields': ('preferred_supplier_id', 'purchaser_id', 'lead_time', 'moq')
        }),
        ('财务信息', {
            'fields': ('income_account_id', 'cogs_account_id', 'asset_account_id', 'tax_code')
        }),
        ('其他信息', {
            'fields': ('creator', 'modifier', 'remark')
        }),
        ('系统信息', {
            'fields': ('product_id', 'create_time', 'update_time', 'is_deleted'),
            'classes': ('collapse',),
        }),
    )